;;; LaTeX
;;; WARNING: This file is loaded from a hook.

;;; TODO: `beginning-of-defun'/`end-of-defun' should go to next section.

;;; We use the TeX setup.
(require 'init-tex)
(require 'latex-pretty-symbols nil t)

;;; latex-math-preview
;;; Needs dvipng.
;;; With TeXlive, the following packages are needed: psnfss, symbol, zapfding
(when (and (executable-find "dvipng") (require 'latex-math-preview nil t))
  (local-set-key (kbd "C-c p") 'latex-math-preview-expression)
  (local-set-key (kbd "C-c j") 'latex-math-preview-insert-symbol)
  (local-set-key (kbd "C-c C-j") 'latex-math-preview-last-symbol-again)
  ;; Any color package should be filtered out as they will have unexpected impact on coloring.
  (add-to-list 'latex-math-preview-usepackage-filter-alist '("color")))


(with-eval-after-load 'latex ; AUCTeX
  (advice-add 'LaTeX-insert-item :before (lambda () (end-of-line)))

	(with-eval-after-load 'font-latex
    (set-face-foreground 'font-latex-sectioning-5-face "white"))

  ;; TODO: Add "tabu" and "longtabu" to environment list.
	
  (require 'tex-fold)
  (add-hook 'LaTeX-mode-hook 'TeX-fold-mode)
  (add-hook 'find-file-hook 'TeX-fold-buffer t))


(provide 'init-latex)
